<template>
  <div>
    <el-row :gutter="20" class="seachnav">
      <el-col :xs="7" :sm="6" :md="4" :lg="6" :xl="4">
        <span @click="returnWho()"><img :src="returnnormalpress" class="returnnormalpress"/></span>
        <span><img :src="realtimeindex" class="equiplist"/></span>
        <span class="description">站点管理</span>
      </el-col>
    </el-row>
    <div class="outMore">
      <div class="dataTitle">
        查看物联网关信息
      </div>
    </div>
    <div class="addBody">
      <el-form :inline="true" class="demo-form-inline">
        <div class="textTitle">基本信息</div>
      </el-form>
      <el-form :inline="true" class="addMessage" ref="form" :model="gatewayData" label-width="180px">
        <el-form-item label="物联网关编号:">
          <el-input class="readonlyMessage" v-model="gatewayData.asset_no" readonly></el-input>
        </el-form-item>
        <el-form-item label="状态:">
          <el-input class="readonlyMessage" v-model="gatewayData.asset_status" readonly></el-input>
        </el-form-item>
        <el-form-item label="物联网管名称:">
          <el-input class="readonlyMessage" v-model="gatewayData.asset_name" readonly></el-input>
        </el-form-item>
        <el-form-item label="创建时间:">
          <el-input class="readonlyMessage" v-model="gatewayData.create_time" readonly></el-input>
        </el-form-item>
        <el-form-item label="品牌:">
          <el-input class="readonlyMessage" v-model="gatewayData.brand" readonly></el-input>
        </el-form-item>
        <el-form-item label="内存:">
          <el-input class="readonlyMessage" v-model="gatewayData.ram" readonly></el-input>
        </el-form-item>
        <el-form-item label="型号:">
          <el-input class="readonlyMessage" v-model="gatewayData.model" readonly></el-input>
        </el-form-item>
        <el-form-item label="硬盘:">
          <el-input class="readonlyMessage" v-model="gatewayData.rom" readonly></el-input>
        </el-form-item>
        <el-form-item label="序列号:">
          <el-input class="readonlyMessage" v-model="gatewayData.sn" readonly></el-input>
        </el-form-item>
        <el-form-item label="操作系统:">
          <el-input class="readonlyMessage" v-model="gatewayData.asset_os" readonly></el-input>
        </el-form-item>
        <el-form-item label="供应商:">
          <el-input class="readonlyMessage longest" v-model="gatewayData.provider" readonly></el-input>
        </el-form-item>
        <el-form-item label="联系人:">
          <el-input class="readonlyMessage" v-model="gatewayData.contact" readonly></el-input>
        </el-form-item>
        <el-form-item label="联系电话:">
          <el-input class="readonlyMessage" v-model="gatewayData.contact_number" readonly></el-input>
        </el-form-item>
        <el-form-item label="采购时间:">
          <el-input class="readonlyMessage" v-model="gatewayData.purchase_time" readonly></el-input>
        </el-form-item>
        <el-form-item label="保修期:">
          <el-input class="readonlyMessage" v-model="gatewayData.warranty_period" readonly></el-input>
        </el-form-item>
        <el-form-item label="备注:">
          <el-input class="readonlyMessage longest" v-model="gatewayData.remarks" readonly></el-input>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
  import detail from '@/assets/components/detail.png'
  import axios from 'axios'
  import realtimeindex from '@/assets/home/management.png'
  import returnnormalpress from '@/assets/home/returnnormalpress.png'
  export default {
    data() {
      return {
        detail,
        realtimeindex,
        returnnormalpress,
        gatewayData: {},
        getGatewayBody: {
          access_token: localStorage.getItem('access_token'),
          type: 'asset_get',
          data: {
            condition: {
              asset_no: this.$route.query.cid
            }
          }
        }
      }
    },
    mounted() {
      this.getGateway()
    },
    methods: {
      getGateway() {
        axios.post('/asset', this.getGatewayBody, {
          headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
          }
        }).then((res) => {
          if (res.data.data.asset_status === 0) {
            res.data.data.asset_status = '未启用'
          } else {
            res.data.data.asset_status = '已启用'
          }
          this.gatewayData = res.data.data
          console.log(this.gatewayData)
        })
          .catch(function(error) {
            console.log(error)
          })
      },
      returnWho() {
        if (this.$route.query.type === 'edit') {
          this.$router.push({
            path: '/managementSide/mSiteAdmin/editSite',
            query: {
              pid: this.$route.query.pid
            }
          })
        } else {
          this.$router.push({
            path: '/managementSide/mSiteAdmin/addSite',
            query: {
              name: this.$route.query.name,
              project: this.$route.query.project
            }
          })
        }
      },
      lookEquip() {
        this.$router.push({
          path: '/managementSide/mSiteAdmin/lookEquip',
          query: {
          }
        })
      }
    }
  }
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .seachnav{
    width: 60%;
    height: 50px;
    position: fixed;
    z-index: 2;
    top:0;
    bottom: 0;
    line-height: 55px;
    padding-left: 20px;
    .description{
      font-size: 18px;
      color: #333;
      line-height: 10px;
      padding-left: 10px;
    }
    .returnnormalpress{
      vertical-align: middle;
      cursor: pointer;
    }
    .equiplist{
      vertical-align: middle;
      margin-left: 10px;
    }
    .searchinvalid{
      vertical-align: middle;
    }
    .con{
      width: 85%;
      height: 50px;
      float: right;
      margin-right: 20px;
      line-height: 3px;
      padding-left: 0 !important;
      .seachContent{
        font-size:18px;
        font-family:MicrosoftYaHei;
        font-weight:400;
        padding-top: 0px;
        color:rgba(51,51,51,1);
      }
      .seachtitle{
        font-size:12px;
        font-family:MicrosoftYaHei;
        font-weight:400;
        color:rgba(102,102,102,1);
      }
    }
  }
  .addBody{
    height: 350px;
    margin: 20px;
    overflow: auto;
    padding: 0px 20px;
    border: 1px solid #E0E0E0;
    background-color: white;
  }
  /deep/ .returnIndex {
    float: right;
    font-size: 14px;
    cursor: pointer;
    color:rgba(37,183,200,1);
  }
  /deep/ .outMore{
    margin: 20px;
    height: 20px;
    padding-top: 5px;
    border-bottom: none;
  }
  /deep/ .dataTitle {
    height: 16px;
    font-size: 16px;
    color: #323842;
  }
  /deep/ .textTitle {
    color: #323842;
    font-size: 14px;
    font-weight: bold;
    padding:10px 0px;
    border-bottom: 1px solid #E0E0E0;
  }
  /deep/ .addMessage {
    margin: 20px 0px;
    width: 1000px;
  }
  /deep/ .el-form-item {
    margin-bottom: 0px;
    height: 30px;
  }
  /deep/ .el-form--inline .el-form-item__label {
    font-weight: normal;
  }
  /deep/ .el-input__inner {
    height: 30px;
    width: 240px;
  }
  /deep/ .readonlyMessage > input{
    border: none;
  }
  /deep/ .longest {
    width: 700px;
  }
  /deep/ .el-table--border td, .el-table--border th, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed {
    border-right: 1px solid #E3E3E3;
    padding: 4px;
  }
  /deep/ .el-table--border th {
    padding: 3px;
  }
  /deep/ .el-table--striped .el-table__body tr.el-table__row--striped td {
    background: #F0F2F7;
  }
</style>
